/*
 * Author: lin.zehong
 * Date: 2018-12-26 22:17:14
 * Last Modified by: hechunxiong
 * Last Modified time: 2019-08-14 15:20:35
 * Desc: Table 组件
 */

import { tableApi } from "../services/public";

export default {
  namespace: "tableModel",
  state: {
    data: [],
    total: 0,
    current: 1,
    pageSize: 10,
  },
  reducers: {
    save(state, { payload: { data, total, current, pageSize } }) {
      return { ...state, list: data, total, current, pageSize };
    },
  },
  effects: {
    *fetch({ payload }, { call }) {
      const { api, pageSize, pageNum, query } = payload;
      const result = yield call(tableApi, { api, pageNum, pageSize, query });

      return result;
    },
  },
};
